/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>				   All right reserved. 		     </p>
 * 
 * <p>项目名称 ： 	深圳市国省检日常化监管系统         </p>
 * <p>创建者   :	win7 
 * 
 * <p>描   述  :   SiteCheckServiceImpl.java for com.pengtu.gsj.service.impl.zhgl    </p>
 * 
 * <p>最后修改 : $: 2017年8月14日-上午11:27:27 v 1.0.0	 win7   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.zhgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.zhgl.SiteCheckDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.zhgl.SiteCheck;
import com.pengtu.gsj.service.system.SystemManageService;
import com.pengtu.gsj.service.zhgl.SiteCheckService;

/**
 * 
 * SiteCheckServiceImpl
 * 
 * 2017年8月14日 上午11:27:27
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class SiteCheckServiceImpl implements SiteCheckService{
	
	@Autowired
	private SiteCheckDao siteCheckDao;
	
	@Autowired
	private SystemManageService systemManageService;
	
	
	
	@Override
	public void saveSiteCheck(SiteCheck siteCheck){
		siteCheckDao.save(siteCheck);
	}
	
	@Override
	public Page<SiteCheck> findSiteCheck(Page<SiteCheck> page, final QueryFilter queryFilter){
		return siteCheckDao.findPage(page, queryFilter);
	}
	
	@Override
	public SiteCheck getSiteCheckById(String id){
		return siteCheckDao.get(id);
	}
	
	@Override
	public void  delateSiteCheck(SiteCheck siteCheck){
		if(siteCheck.getAttachments() != null){
			for(Attachment attachment : siteCheck.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		siteCheckDao.delete(siteCheck);
	}
	
	@Override
	public List<SiteCheck> getSiteCheckGroupByRoadName(QueryFilter queryFilter){
		return siteCheckDao.find(queryFilter, "testYear", true);
	}
	
}
